package com.yl.ydk.base

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
import com.yl.ydk.utils.CrashUtils
import com.yl.ydk.utils.PreferUtil
import com.blankj.utilcode.utils.ThreadPoolUtils
import com.blankj.utilcode.utils.Utils
import com.tencent.rtmp.TXLiveBase





class BaseApplication : Application() {

    // 获取到的 licence url
    val licenceURL =
        "http://license.vod2.myqcloud.com/license/v1/226481168a5c7ac5fafa570bbbf58753/TXLiveSDK.licence"
    // 获取到的 licence key
    val licenceKey = "1d50fd96d3daa6d4df5fa7506a031150"

    companion object {
        @SuppressLint("StaticFieldLeak")
        private var mContext: Context? = null
        @SuppressLint("StaticFieldLeak")
        private var instance: BaseApplication? = null
        var MAIN_EXECUTOR = ThreadPoolUtils(ThreadPoolUtils.Type.FixedThread, 20)
        fun getContext(): Context? {
            return mContext
        }

        fun getInstance(): BaseApplication? {
            return instance
        }
    }

    override fun onCreate() {
        super.onCreate()
        mContext = applicationContext
        Utils.init(this)
        PreferUtil.getInstance().init(this)
        CrashUtils.getInstance().init()

        TXLiveBase.getInstance().setLicence(this, licenceURL, licenceKey)
        instance = this

    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }


}